package com.molichuxing.services.infrastructure.service.impl;

import com.molichuxing.services.infrastructure.bean.MotStateLogBean;
import com.molichuxing.services.infrastructure.dao.MotLogMapper;
import com.molichuxing.services.infrastructure.dao.MotStateLogMapper;
import com.molichuxing.services.infrastructure.dto.request.create.ThirdMotStateCreateDto;
import com.molichuxing.services.infrastructure.service.MotLogStateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("motLogStateService")
public class MotLogStateServiceImpl  implements MotLogStateService {

    private static final Logger logger = LoggerFactory.getLogger(MotLogStateServiceImpl.class);

    @Resource
    MotStateLogMapper motStateLogMapper;

    @Override
    public Integer createMotLogState(ThirdMotStateCreateDto createDto) {
        logger.info("第三方年检订单状态入库 >>> {}",createDto);

        try{
            MotStateLogBean bean = new MotStateLogBean();
            if(createDto!=null){
                BeanUtils.copyProperties(createDto,bean);
                return motStateLogMapper.create(bean);
            }
        }catch (Exception e){
            logger.info("第三方年检 >>> 入库车辆状态异常：{}",createDto.toString());
            e.printStackTrace();
        }
        return 0;
    }
}
